<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Configure Farmbot's Network </title>
    <link rel="stylesheet" href="/styles.css">
    <script>
      function securityChange() {
        if(document.getElementById("security").value != "NONE") {
          document.getElementById("pskdiv").hidden = false;
        } else {
          document.getElementById("pskdiv").hidden = true;
        }
      }
      function showPassword() {
        var x = document.getElementById("psk");
        if (x.type === "password") {
            x.type = "text";
        } else {
            x.type = "password";
        }
      }
    </script>
  </head>

  <body>
    <h1>Configure your FarmBot</h1>
    <div class="widget">
      <div class="widget-header"> <h5>Configure Wireless</h5> </div>
      <div class="widget-content">
        <form action=<%= post_action %> method="post">
          <fieldset>
            <label>Network Name</label>
            <input name="ssid_fake" type="text" value="<%= ssid %>" disabled>
            <input name="ssid" type="text" value="<%= ssid %>" hidden>
            <input name="ifname"  hidden value="<%= ifname   %>">

            <label for="security"> Security Type </label>
            <select name="security" id="security" onchange="securityChange()">
              <option value="WPA-PSK"> WPA2-PSK </option>
              <option value="WPA-PSK"> WPA-PSK </option>
              <option value="NONE"> NONE </option>
            </select>

            <div id="pskdiv">
              <label for=psk> PASSWORD </label>
              <div class="psk-input-group">
                <input type="password" name="psk" id="psk">
                <img class="eye-icon" src="icon_eye.svg"
                  onclick="showPassword()" title="Show password">
              </div>
            </div>

            <%= advanced_network %>

          </fieldset>

          <div class="button"> <input type=submit value="next"> </div>
        </form>
      </div>
    </div>
  </body>
</html>
